/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.gatech.egg.l0cUs.persistence;

import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.orm.jpa.persistenceunit.MutablePersistenceUnitInfo;
import org.springframework.orm.jpa.persistenceunit.PersistenceUnitPostProcessor;

/**
 *
 * @author summerspittman
 */
public class JtaPersistenceUnitPostProcessor implements PersistenceUnitPostProcessor {

    private DataSource jtaDataSource;

    public void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo pui) {
        pui.setJtaDataSource(getJtaDataSource());

    }

    /**
     * getter for jtaDataSource
     *
     * @return the JTA capable datasource supplied via the setter
     */
    public DataSource getJtaDataSource() {
        return jtaDataSource;
    }

    /**
     * setter for jtaDataSource
     *
     * @param jtaDataSource the JTA capable datasource added to the PersistenceUnitInfo during post processing
     */
    @Required
    public void setJtaDataSource(DataSource jtaDataSource) {
        this.jtaDataSource = jtaDataSource;
    }
}
